set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BINARY_OUTPUT_DIRECTORY}/apps)
if(WIN32)
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()

if(APPLE)
  set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
  if(NOT BUILD_MAC_APP_BUNDLE)
    set(CMAKE_MACOSX_RPATH TRUE)
  endif()
else()
  set(CMAKE_INSTALL_RPATH "\${ORIGIN}/../lib")
endif()
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

option(BUILD_MNE_SCAN "Build MNE Scan" ON)
option(BUILD_MNE_ANALYZE "Build MNE Analyze" ON)
option(BUILD_MNE_ANONYMIZE "Build MNE Anonymize" ON)
option(BUILD_MNE_RT_SERVER "Build MNE Rt Server" ON)
option(BUILD_MNE_FORWARD_SOLUTION "Build MNE Forward Solution" ON)
option(BUILD_MNE_EDF2FIFF "Build MNE edf to fiff" ON)
option(BUILD_MNE_DIPOLE_FIT "Build MNE Dipole Fit" ON)

option(APPS_REALTIME "Build only realtime apps" OFF)
if(APPS_REALTIME)
  set(BUILD_MNE_SCAN ON)
  set(BUILD_MNE_ANALYZE OFF)
  set(BUILD_MNE_ANONYMIZE OFF)
  set(BUILD_MNE_RT_SERVER ON)
  set(BUILD_MNE_FORWARD_SOLUTION OFF)
  set(BUILD_MNE_EDF2FIFF OFF)
  set(BUILD_MNE_DIPOLE_FIT OFF)
endif()

option(APPS_OFFLINE "Build only offline apps" OFF)
if(APPS_OFFLINE)
  set(BUILD_MNE_SCAN OFF)
  set(BUILD_MNE_ANALYZE ON)
  set(BUILD_MNE_ANONYMIZE ON)
  set(BUILD_MNE_RT_SERVER OFF)
  set(BUILD_MNE_FORWARD_SOLUTION ON)
  set(BUILD_MNE_EDF2FIFF ON)
  set(BUILD_MNE_DIPOLE_FIT ON)
endif()

if(BUILD_MNE_ANONYMIZE)
  add_subdirectory(mne_anonymize)
endif()
  if(BUILD_MNE_ANALYZE)
    add_subdirectory(mne_analyze)
  endif()
if(NOT WASM)
  if(BUILD_MNE_SCAN)
    add_subdirectory(mne_scan)
  endif()
  if(BUILD_MNE_RT_SERVER)
    add_subdirectory(mne_rt_server)
  endif()
  if(BUILD_MNE_FORWARD_SOLUTION)
    add_subdirectory(mne_forward_solution)
  endif()
  if(BUILD_MNE_EDF2FIFF)
    add_subdirectory(mne_edf2fiff)
  endif()
  if(BUILD_MNE_DIPOLE_FIT)
    add_subdirectory(mne_dipole_fit)
  endif()
endif()
